home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / URL Helper II / Source / mainLibTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-14  |  1.8 KB  |  78 lines  |  [TEXT/MMCC]

  1. /***
  2.  * main.c
  3.  *
  4.  *  Tester routine for the URLHelper component.  This routine will try to exercise all the
  5.  *  various facets of the component.
  6.  *
  7.  ***/
  8. #include "debug_me.h"
  9. #include <stdio.h>
  10. #include "URLHLibrary.h"
  11.  
  12. char *StrPrint (StringPtr string);
  13. void Lib1Sub (StringPtr string);
  14. void LibAllSub (StringPtr string);
  15.  
  16. /**
  17.  ** Global stuff we need if we are debugging -- this is because we have to supply
  18.  ** all the info about the component when we register.
  19.  **/
  20.  
  21. void main () {
  22.  
  23.     Lib1Sub("\pftp://sumex-aim.stanford.edu/info-mac/grf/util/mac-graphics.hqx");
  24.     Lib1Sub("\pgopher://sumex-aim.stanford.edu/info-mac/per/im/infomacv12-044.txt");
  25.     Lib1Sub("\pgopher://mac.archive.umich.edu/pub/system/updates/long/dir/help.txt");
  26.     LibAllSub("\pftp://sumex-aim.stanford.edu/info-mac/grf/util/mac-graphics.hqx");
  27.     LibAllSub("\pgopher://sumex-aim.stanford.edu/info-mac/per/im/infomacv12-044.txt");
  28.     LibAllSub("\pgopher://mac.archive.umich.edu/pub/system/updates/long/dir/help.txt");
  29.  
  30.     return;
  31. }
  32.  
  33. /**
  34.  * StrPrint
  35.  *
  36.  *  Dump a string to printf...
  37.  *
  38.  **/
  39. char * StrPrint (StringPtr str)
  40. {
  41.  
  42.     static char    string[256];
  43.     
  44.     BlockMove (str+1, string, str[0]);
  45.     string[str[0]] = '\0';
  46.     return string;
  47. }
  48.  
  49. /**
  50.  * Lib1Sub
  51.  *
  52.  *  Use the library to get the primary miirror back
  53.  **/
  54. void Lib1Sub (StringPtr string)
  55. {
  56.     Str255        mirror;
  57.  
  58.     printf ("Getting primary mirror for '%s'\n", StrPrint(string));
  59.     URLHLibGetFirstMirror (string, mirror);
  60.     printf ("And it is: '%s'\n", StrPrint(mirror));
  61. }
  62.  
  63. void LibAllSub (StringPtr string)
  64. {
  65.     short            index;
  66.     URLHParseRef    parseRef;
  67.     Str255            mirror;
  68.  
  69.     printf ("Getting all mirrors for '%s'\n", StrPrint(string));
  70.     parseRef = URLHLibNewParseState (string);
  71.     index = 1;
  72.     while (URLHLibGetIndexedMirror (parseRef, index, mirror)) {
  73.         printf ("-> '%s'\n", StrPrint(mirror));
  74.         index++;
  75.     }
  76.     URLHLibDisposeParseState (parseRef);
  77. }
  78.